<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>
Should see "bar" centered in its own red box. The "foo" and "baz" lines should not be centered.
</p>
<div id="sample" contenteditable>foo<div>bar</div>baz</div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    selection.collapse(sample.childNodes[1].firstChild, 0);
    document.execCommand('justifyCenter');

    assert_equals(sample.innerHTML, 'foo<div style="text-align: center;">bar</div>baz', 'innerHTML');
    assert_true(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, sample.childNodes[1].firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
});
</script>
